#! /bin/sh

bspc monitor -d I II III IV V VI VII VIII IX X

. "${HOME}/.config/bspwm/color"

$HOME/.config/bspwm/autostart.sh

bspc config border_width         2
bspc config normal_border_color "$color8"
bspc config active_border_color "$color7"
bspc config focused_border_color "$color6"
bspc config presel_feedback_color "$color0"

SPACES=$(bspc query -D)
for SPACE in $SPACES
do
  bspc config -d ${SPACE} window_gap      10
  bspc config -d ${SPACE} top_padding     25
  bspc config -d ${SPACE} bottom_padding  25
  bspc config -d ${SPACE} left_padding   50
  bspc config -d ${SPACE} right_padding  50
done

bspc config automatic_scheme      spiral
bspc config split_ratio           0.5
bspc config borderless_monocle    true
bspc config gapless_monocle       false
bspc config single_monocle        true
bspc config focus_follows_pointer true

bspc desktop ^1 -l monocle
bspc desktop ^2 -l monocle
bspc desktop ^5 -l monocle
bspc desktop ^6 -l monocle
bspc desktop ^9 -l monocle
bspc desktop ^10 -l monocle

# Rules
bspc rule -a Alacritty:Tiled desktop='^1' follow=on
bspc rule -a Alacritty:Tmux desktop='^1' follow=on
bspc rule -a Chromium desktop='^2'
bspc rule -a firefox desktop='^2'
bspc rule -a Subl3 desktop='^3'
# bspc rule -a Thunar desktop='^4' state=pseudo_tiled
bspc rule -a Thunar desktop='^4' follow=on focus=on
bspc rule -a Thunar:Dialog state=floating center=true
bspc rule -a TelegramDesktop desktop='^5' follow=on
bspc rule -a discord desktop='^5' follow=on
bspc rule -a Gimp-2.10 desktop='^6'
bspc rule -a Inkscape desktop='^6'
bspc rule -a kdenlive desktop='^6'
bspc rule -a Audacious desktop='^7' state=floating follow=on focus=on
bspc rule -a Zathura desktop='^7' state=tiled follow=on
bspc rule -a Xreader desktop='^7' state=tiled follow=on
bspc rule -a '*:libreoffice' desktop='^8' state=tiled
bspc rule -a '*:soffice' desktop='^8'
bspc rule -a Gnome-chess desktop='^9'
bspc rule -a teeworlds desktop='^9'
bspc rule -a Steam desktop='^9' state=floating
bspc rule -a "VirtualBox Manager" desktop='^10'


bspc rule -a Alacritty:Newsboat state=floating center=on
bspc rule -a Alacritty:Ranger state=floating center=on
bspc rule -a URxvt:Ranger state=floating center=on
bspc rule -a Alacritty:Pacui state=floating center=on
bspc rule -a Alacritty:Float state=floating
bspc rule -a Alacritty:Draw state=floating
bspc rule -a Galculator state=floating
bspc rule -a Gpick state=floating
bspc rule -a GParted state=floating
bspc rule -a File-roller state=floating
bspc rule -a Nitrogen state=floating
bspc rule -a Lxappearance state=floating center=true
bspc rule -a Lxrandr state=floating
bspc rule -a Pavucontrol state=floating
bspc rule -a Timeshift-gtk state=floating
bspc rule -a qt5ct state=floating rectangle=700x470+0+0 center=on
bspc rule -a SimpleScRRRRRecorder state=floating
bspc rule -a Sxiv state=floating
bspc rule -a Viewnior state=floating
bspc rule -a SMPlayer state=floating
bspc rule -a mpv state=floating sticky=on rectangle=300x180+1060+475

bscp rule -a polybar manage=off
bspc rule -a Tint2 border=off manage=off layer=above state=floating
# bspc rule -a Mylaunchpad border=off manage=off
bspc rule -a '*:Kunst' sticky=on layer=below border=off focus=off
# bspc rule -a Sxiv:Kunst sticky=on layer=below border=off focus=off manage=off rectangle=250x250+1055+60

# Set Desktop 7 to start with floating windows
FLOATING_DESKTOP_ID=$(bspc query -D -d '^7')
bspc subscribe node_manage | while read -a msg ; do
	desk_id=${msg[2]}
	wid=${msg[3]}
	[ "$FLOATING_DESKTOP_ID" = "$desk_id" ] && bspc node "$wid" -t floating
done
